home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
130 MIDI Tool Box
/
130 MIDI Tool Box.iso
/
mpu401
/
shopat.c
< prev
Wrap
C/C++ Source or Header
|
1986-11-02
|
4KB
|
203 lines
/* Copyright (C) 1986 by M. J. Shannon, Jr.
** Permission to distribute for non-commercial uses granted as long as this
** notice is retained. Violators will be prosecuted.
*/
#include <stdio.h>
#include <dos.h>
#include <fcntl.h>
void dump_op(int, char *);
char patch_buf[0x66];
char ftp[6];
char disp[5][24];
char *head0[13] =
{
"Alg",
"FBL",
"LFW",
"LFS",
"LFD",
"PMD",
"AMD",
"SYNC",
"PMS",
"AMS",
"AME",
"EGS",
"KV"
};
char *head1[11] =
{
"OFR",
"DET",
"AR",
"D1R",
"D1L",
"D2R",
"RR",
"OL",
"KSR",
"KSL",
"TRAN"
};
char *head2[12] =
{
"POLY",
"PBR",
"PMO",
"PMT",
"[FV]",
"FSW",
"PWR",
"AWR",
"BPR",
"BAR",
"BPB",
"BEB"
};
main(argc, argv, envp)
int argc;
char **argv;
char **envp;
{
FILE *fp;
char *pb = &patch_buf[0];
int fh;
long ft;
int i, j;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
if (argc < 2)
{
fprintf(stderr, "Need an argument.\n");
exit(1);
}
fh = open(argv[1], O_RDONLY|O_RAW);
if (fh == -1)
{
fprintf(stderr, "Can't open <%s>.\n", argv[1]);
exit(1);
}
ft = getft(fh);
fp = fdopen(fh, "rb");
if (!fp)
{
fprintf(stderr, "Can't fdopen <%s>.\n", argv[1]);
exit(1);
}
fread(patch_buf, sizeof patch_buf, 1, fp);
fclose(fp);
printf("Header: %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n",
pb[0] & 0xFF, pb[1] & 0xFF, pb[2], pb[3], pb[4], pb[5], pb[6]);
printf("DATA NAME:\t%10.10s\n", &pb[84]);
ftunpk(ft, &ftp[0]);
printf("DATE:\t\t%2d/%2d/%2d\n", ftp[0] + 80, ftp[1], ftp[2]);
printf("\n");
for (i = 0; i < 5; ++i)
for (j = 0; j < 24; ++j)
disp[i][j] = -1;
dump_op(1, &pb[46]);
dump_op(2, &pb[20]);
dump_op(3, &pb[33]);
dump_op(4, &pb[ 7]);
disp[2][0] = pb[59]; /* ALG */
disp[2][1] = pb[60]; /* FBL */
disp[2][2] = pb[66]; /* LW */
disp[2][3] = pb[61]; /* LFS */
disp[2][4] = pb[62]; /* LFD */
disp[2][5] = pb[63]; /* PMD */
disp[2][6] = pb[64]; /* AMD */
disp[2][7] = pb[65]; /* SYNC */
disp[2][8] = pb[67]; /* PMS */
disp[2][9] = pb[68]; /* AMS */
disp[2][23] = pb[69]; /* XPOSE */
disp[4][0] = pb[70]; /* POLY */
disp[4][1] = pb[71]; /* PBR */
disp[4][2] = pb[72]; /* PMO */
disp[4][3] = pb[73]; /* PMT */
disp[4][4] = pb[74]; /* [FV] */
disp[4][5] = pb[75] | (pb[76] << 1); /* FSW */
disp[4][6] = pb[77]; /* [CS] */
disp[4][6] = pb[78]; /* PWR */
disp[4][7] = pb[79]; /* AWR */
disp[4][8] = pb[80]; /* BPR */
disp[4][9] = pb[81]; /* BAR */
disp[4][10] = pb[82]; /* BPB */
disp[4][11] = pb[83]; /* BEB */
printf(" ");
for (i = 0; i < 13; ++i)
printf(" %4.4s", head0[i]);
printf("\n");
for (i = 0; i < 4; ++i)
{
printf("OP%d:", i + 1);
for (j = 0; j < 13; ++j)
{
if (disp[i][j] == -1)
printf(" ");
else
printf(" %.4d", disp[i][j]);
}
printf("\n");
}
printf("\n");
printf(" ");
for (i = 0; i < 11; ++i)
printf(" %4.4s", head1[i]);
printf("\n");
for (i = 0; i < 4; ++i)
{
printf("OP%d:", i + 1);
for (j = 13; j < 24; ++j)
{
if (disp[i][j] == -1)
printf(" ");
else
printf(" %.4d", disp[i][j]);
}
printf("\n");
}
printf("\n");
printf(" ");
for (i = 0; i < 12; ++i)
printf(" %4.4s", head2[i]);
printf("\n");
printf(" ");
for (j = 0; j < 12; ++j)
{
if (disp[4][j] == -1)
printf(" ");
else
printf(" %.4d", disp[4][j]);
}
printf("\n");
fflush(stdout);
fflush(stderr);
return (0);
}
void
dump_op(op, pb)
int op;
char *pb;
{
--op;
disp[op][10] = pb[8]; /* AME */
disp[op][11] = pb[7]; /* EGB */
disp[op][12] = pb[9]; /* KV */
disp[op][13] = pb[11]; /* FR */
disp[op][14] = pb[12]; /* DET */
disp[op][15] = pb[0]; /* AR */
disp[op][16] = pb[1]; /* D1R */
disp[op][17] = pb[4]; /* D1L */
disp[op][18] = pb[2]; /* D2R */
disp[op][19] = pb[3]; /* RR */
disp[op][20] = pb[10]; /* OL */
disp[op][21] = pb[6]; /* KSR */
disp[op][22] = pb[5]; /* KSL */
}